package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.CommunalTitle;
import com.cn.wanxi.util.model.ConpanyIdeaModel;
import com.cn.wanxi.util.model.SchoolContacModel;
import com.cn.wanxi.util.model.SchoolNewsModel;

import java.util.ArrayList;
import java.util.List;

public class SchoolContent2Utile {
    FileUtile fileUtile = new FileUtile();

    public List<ConpanyIdeaModel> readConpanyIdeaFile() {
        List<ConpanyIdeaModel> conpanyIdeaModelList = new ArrayList<>();
        String Idea = fileUtile.readFileToString("ConpanyIdeaFile.txt");
        String[] Ideas = Idea.split(";");
        for (int i = 0; i < Ideas.length; i++) {
            String item = Ideas[i];
            String[] info = item.split(",");
            ConpanyIdeaModel conpanyIdeaModel = new ConpanyIdeaModel(info[0].trim(), info[1].trim(), info[2].trim());
            conpanyIdeaModelList.add(conpanyIdeaModel);
        }
        return conpanyIdeaModelList;
    }

    public List<SchoolNewsModel> readSchoolNews() {
        List<SchoolNewsModel> schoolNewsList = new ArrayList<>();
        String news = fileUtile.readFileToString("SchoolNewsModelFile.txt");
        String[] newes = news.split(";");
        for (int i = 0; i < newes.length; i++) {
            String item = newes[i];
            String[] info = item.split(",");
            SchoolNewsModel schoolNewsModel = new SchoolNewsModel(info[0].trim(), info[1].trim(), info[2].trim(), info[3].trim(), info[4].trim());
            schoolNewsList.add(schoolNewsModel);
        }
        return schoolNewsList;
    }

    public List<SchoolContacModel> readSchoolContac() {
        List<SchoolContacModel> schoolContacList = new ArrayList<>();
        String contac = fileUtile.readFileToString("SchoolContacFile.txt");
        String[] contacs = contac.split(";");
        for (int i = 0; i < contacs.length; i++) {
            String item = contacs[i];
            String[] info = item.split(",");
            SchoolContacModel schoolContacModel = new SchoolContacModel(info[0].trim(), info[1].trim(), info[2].trim(), info[3].trim());
            schoolContacList.add(schoolContacModel);
        }
        return schoolContacList;
    }

}
